function [output subjectinfo] = scoreTfcPeaks (subjectinfo, cfg)

if ~exist('cfg','var'); cfg = scoreTfcPeaks_defaultCfg(); end;

tStart = tic;
output = [];
fnES = fieldnames(subjectinfo.EpochData);

for i = 1:length(fnES)
    currentEpochset = fnES{i};
    disp (currentEpochset);    
    nrOfEpochs = subjectinfo.EpochData.(currentEpochset).nrOfEpochsFound;
    TfcDatafile = subjectinfo.EpochData.(currentEpochset).TfcDatafile;
    
    %% Load the data
    disp(['Loading data from ''' TfcDatafile '''']);
    load(TfcDatafile);
    
    %% Score the peaks
    disp('Scoring peaks...');
    electrodes = fieldnames(tfc.data);
    warning('off', 'all');
    for j=1:length(electrodes) % all electrodes
        electrode = cell2mat(electrodes(j));
        for k=1:length(tfc.data.(electrode)) % all freq.bins
            tfc.data.(electrode)(k) = scorePeaks(tfc.data.(electrode)(k), times, nrOfEpochs, cfg);
        end
    end
    warning('on', 'all');
    
    % Save the data
    disp('Saving data...');
    save(TfcDatafile, '-v7.3', 'tfc');
    
end
output.TimePassed = toc(tStart);
end